package artid.com.arttogo.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 名人艺术家详情实体类+解析
 */

public class CelebritySealInfoParser extends AppItem implements Serializable {
    private String id;//名人艺术家id
    private String realname;//名字
    private String describe;//描述
    private String userimage;//名人艺术家头像
    private int imagenum;//印章数量
    private List<CelebritySealInfo_ImageInfo> imageinfo = new ArrayList<CelebritySealInfo_ImageInfo>();//印章图片

    @Override
    public void parse(JSONObject obj) {
        if (null == obj) {
            return;
        }
        id = obj.optString("id");
        realname = obj.optString("realname");
        describe = obj.optString("describe");
        userimage = obj.optString("userimage");
        imagenum = obj.optInt("imagenum");
        JSONArray Arr = obj.optJSONArray("imageinfo");
        for (int i = 0; i < Arr.length(); i++) {
            CelebritySealInfo_ImageInfo mImageInfo = new CelebritySealInfo_ImageInfo();
            try {
                mImageInfo.setId(Arr.optJSONObject(i).getString("id"));
                mImageInfo.setPath(Arr.optJSONObject(i).getString("path"));
                mImageInfo.setHeight(Arr.optJSONObject(i).getString("height"));
                mImageInfo.setName(Arr.optJSONObject(i).getString("name"));
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            imageinfo.add(mImageInfo);
        }
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }

    public String getUserimage() {
        return userimage;
    }

    public void setUserimage(String userimage) {
        this.userimage = userimage;
    }

    public int getImagenum() {
        return imagenum;
    }

    public void setImagenum(int imagenum) {
        this.imagenum = imagenum;
    }

    public List<CelebritySealInfo_ImageInfo> getImageinfo() {
        return imageinfo;
    }

    public void setImageinfo(List<CelebritySealInfo_ImageInfo> imageinfo) {
        this.imageinfo = imageinfo;
    }

    public CelebritySealInfoParser() {
    }

    public CelebritySealInfoParser(String id, String realname, String describe, String userimage, int imagenum, List<CelebritySealInfo_ImageInfo> imageinfo) {
        this.id = id;
        this.realname = realname;
        this.describe = describe;
        this.userimage = userimage;
        this.imagenum = imagenum;
        this.imageinfo = imageinfo;
    }

    @Override
    public String toString() {
        return "CelebritySealInfoParser{" +
                "id='" + id + '\'' +
                ", realname='" + realname + '\'' +
                ", describe='" + describe + '\'' +
                ", userimage='" + userimage + '\'' +
                ", imagenum=" + imagenum +
                ", imageinfo=" + imageinfo +
                '}';
    }

    public class CelebritySealInfo_ImageInfo implements Serializable {
        private String id;
        private String path;
        private String height;
        private String name;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getPath() {
            return path;
        }

        public void setPath(String path) {
            this.path = path;
        }

        public String getHeight() {
            return height;
        }

        public void setHeight(String height) {
            if(height.contains("."))
                height = height.substring(0,height.indexOf("."));
            this.height = height;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public CelebritySealInfo_ImageInfo() {
        }

        public CelebritySealInfo_ImageInfo(String id, String path, String height, String name) {
            this.id = id;
            this.path = path;
            this.height = height;
            this.name = name;
        }

        @Override
        public String toString() {
            return "CelebritySealInfo_ImageInfo{" +
                    "id='" + id + '\'' +
                    ", path='" + path + '\'' +
                    ", height='" + height + '\'' +
                    ", name='" + name + '\'' +
                    '}';
        }
    }
}
